package com.zjitc.utils;

import com.google.gson.Gson;
import com.zjitc.dao.ProductDao;
import com.zjitc.model.Product;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/5/30 14:26
 * @description:
 */
@Component
public class NoSql {

  @Autowired
  public NoSql(Redis redis,ProductDao productDao){
    Gson gson=new Gson();
    List<Product> newProduct = productDao.findNewProduct();
    List<Product> hotProduct=productDao.findHotProduct();
    String nProduct=gson.toJson(newProduct);
    String hProduct=gson.toJson(hotProduct);
    redis.set("newProduct",nProduct);
    redis.set("hotProduct",hProduct);
  }
}
